﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using log4net;

namespace Windvoice.Framework
{
    [WindvoiceBasicAttribute]
    public class ControllerBase : Controller
    {
        private ILog ErrorLogger
        {
            get { return LogManager.GetLogger("errorlogger"); }
        }

        public JsonResult AjaxResult(bool result = true, string message = "")
        {
            return Json(new { result = result, message = message },JsonRequestBehavior.AllowGet);
        }

        protected override void OnException(ExceptionContext filterContext)
        {
            ErrorLogger.Info(String.Format("exception hit, url:{0}",filterContext.HttpContext.Request.RawUrl));
            ErrorLogger.Error(filterContext.Exception);

            base.OnException(filterContext);
        }
    }
}
